package com.ruoyi.web.controller.websql;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.websql.domain.SqlDriverConfig;
import com.ruoyi.websql.service.ISqlDriverConfigService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * ***Controller
 * 
 * @author xudengyu
 * @date 2025-03-18
 */
@RestController
@RequestMapping("/websql/driverConfig")
public class SqlDriverConfigController extends BaseController
{
    @Resource
    private ISqlDriverConfigService SqlDriverConfigService;

    @GetMapping("/getById/{id}")
    public AjaxResult getById(@PathVariable("id") Long id){
        SqlDriverConfig sqlDriverConfig = new SqlDriverConfig();
        sqlDriverConfig.setID(id);
        return AjaxResult.success(SqlDriverConfigService.selectSqlDriverConfigList(sqlDriverConfig));
    }

    @GetMapping("/getDriverConfigList")
    public AjaxResult getDriverConfigList()
    {
        List<SqlDriverConfig> list = SqlDriverConfigService.selectSqlDriverConfigList(new SqlDriverConfig());
        return AjaxResult.success(list);
    }

    /**
     * 查询***列表
     */
    @PreAuthorize("@ss.hasPermi('websql:driverConfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(SqlDriverConfig SqlDriverConfig)
    {
        startPage();
        List<SqlDriverConfig> list = SqlDriverConfigService.selectSqlDriverConfigList(SqlDriverConfig);
        return getDataTable(list);
    }

    /**
     * 导出***列表
     */
    @PreAuthorize("@ss.hasPermi('websql:driverConfig:export')")
    @Log(title = "***", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SqlDriverConfig SqlDriverConfig)
    {
        List<SqlDriverConfig> list = SqlDriverConfigService.selectSqlDriverConfigList(SqlDriverConfig);
        ExcelUtil<SqlDriverConfig> util = new ExcelUtil<SqlDriverConfig>(SqlDriverConfig.class);
        util.exportExcel(response, list, "***数据");
    }

    /**
     * 获取***详细信息
     */
    @PreAuthorize("@ss.hasPermi('websql:driverConfig:query')")
    @GetMapping(value = "/{dbCheckUrl}")
    public AjaxResult getInfo(@PathVariable("dbCheckUrl") String dbCheckUrl)
    {
        return success(SqlDriverConfigService.selectSqlDriverConfigByDbCheckUrl(dbCheckUrl));
    }

    /**
     * 新增***
     */
    @PreAuthorize("@ss.hasPermi('websql:driverConfig:add')")
    @Log(title = "***", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SqlDriverConfig SqlDriverConfig)
    {
        return toAjax(SqlDriverConfigService.insertSqlDriverConfig(SqlDriverConfig));
    }

    /**
     * 修改***
     */
    @PreAuthorize("@ss.hasPermi('websql:driverConfig:edit')")
    @Log(title = "***", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SqlDriverConfig SqlDriverConfig)
    {
        return toAjax(SqlDriverConfigService.updateSqlDriverConfig(SqlDriverConfig));
    }

    /**
     * 删除***
     */
    @PreAuthorize("@ss.hasPermi('websql:driverConfig:remove')")
    @Log(title = "***", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dbCheckUrls}")
    public AjaxResult remove(@PathVariable String[] dbCheckUrls)
    {
        return toAjax(SqlDriverConfigService.deleteSqlDriverConfigByDbCheckUrls(dbCheckUrls));
    }
}
